package com.last.controller;

import com.last.entity.DataDTO;
import com.last.entity.PageResult;
import com.last.entity.Result;
import com.last.entity.RoomInfo;
import com.last.service.IRoomInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/roomManager")
public class RoomInfoController {

    @Autowired
    private IRoomInfoService roomInfoService;

    @PostMapping("/search") // 房屋信息列表+条件查询+分页
    public PageResult search(@RequestBody DataDTO<RoomInfo> dataDTO){
        PageResult<RoomInfo> searchResult = roomInfoService.search(dataDTO);
        return searchResult;
    }

    @PostMapping("/review") // 审核通过
    public Result review(@RequestBody RoomInfo roomInfo){
        Result result = roomInfoService.setRoomStatus(roomInfo);
        return result;
    }

    @PostMapping("/noPass") // 设置成不通过
    public Result noPass(@RequestBody RoomInfo roomInfo){
        Result result = roomInfoService.setRoomStatusNoPass(roomInfo);
        return result;
    }


}
